Skip to content

Suggest mode: Auto-save subsystem (Phase 6)#78308

Open
adamsilverstein wants to merge 1 commit into
phase-5b-collab-sidebar-actionsfrom
suggest-mode-autosave
Open

Suggest mode: Auto-save subsystem (Phase 6)#78308
adamsilverstein wants to merge 1 commit into
phase-5b-collab-sidebar-actionsfrom
suggest-mode-autosave

Conversation

@adamsilverstein
Copy link
Copy Markdown
Member

@adamsilverstein adamsilverstein commented May 14, 2026

Overview

Follow-up to #77407 (Phase 5). Carves the auto-save subsystem out of Phase 5 so each PR concentrates on one concern — Phase 5 stays focused on REST permissions + PHP tests, and this PR owns the Google Docs–style background save.

Tracked in #73411.

What's in this PR

  • SuggestionAutoSave — invisible component that debounces overlay edits (1.5 s per block) and persists them as note comments with the _wp_suggestion meta payload. Replaces the explicit SuggestionCommitBar toolbar button (restored on Phase 5 so the prior stack stays functional in isolation).
  • Per-block save queue — saves on the same clientId chain sequentially so a slow network call can't race with a follow-up edit and produce duplicate POSTs or out-of-order writes. Different blocks run concurrently.
  • updateSuggestion / deleteSuggestion on the provider — once a comment id is linked, subsequent edits PUT the same comment; a fully reverted overlay trashes the note. Includes a stale-link check via core-data so a peer-resolved comment doesn't get clobbered mid-session.
  • Overlay plumbingcommentId and syncedOpsKey fields on overlay entries, SET_COMMENT_ID / SET_SYNCED_OPS_KEY reducer cases, and matching setCommentId / setSyncedOpsKey callbacks on the context.
  • Tests — `test/auto-save.js` covers debounce, queue ordering, create/update/delete branching, and stale-link orphan handling. `test/overlay-context.js` covers the new reducer cases.

Test plan

  1. Enter Suggest mode and edit a paragraph.
  2. After ~1.5 s the network shows a `POST /wp/v2/comments` creating the note.
  3. Continue typing — subsequent saves are `PUT`s against the same comment id.
  4. Revert the overlay to baseline — the note is trashed.
  5. Have a peer accept the suggestion mid-session — the next local edit creates a fresh comment instead of clobbering the resolved one.

```bash
npm run test:unit -- packages/editor/src/components/suggestion-mode/
```

Stack

🗺️ PR Stack Navigation

# PR Phase
1 #77403 Intent scaffolding Edit / Suggest / View mode
2 #77404 Overlay capture In-memory suggestion overlay
3 #77405 Provider + Accept/Reject _wp_suggestion meta, provider, sidebar actions
4 #77406 Summary + docs + attribute tests Add/Delete/Formatting summary, architecture stub, conflict scoping
5a #78351 REST permissions and PHP coverage Permissions, payload cap, PHP tests
5b #78352 Summary + attribute conflict + docs Renderer, per-attribute staleness, architecture docs
5c #78353 Surface Apply/Reject in the collaboration sidebar Icon buttons + e2e + sidebar wiring
6 #78308 Auto-save subsystem ← this PR Background debounced save (replaces commit-bar)

📋 Tracking issue: #73411

@github-actions github-actions Bot added the [Package] Editor /packages/editor label May 14, 2026
@github-actions
Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: adamsilverstein <adamsilverstein@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Per-block debounced background save for Suggest mode. After a 1.5 s idle
window, pending overlay edits persist as a note comment; subsequent
edits on the same block update the existing note's meta rather than
creating a new one, and a fully reverted overlay trashes the note.
Saves on the same clientId run sequentially via a per-block promise
queue, while different blocks run concurrently. Replaces the explicit
SuggestionCommitBar toolbar button.
@adamsilverstein adamsilverstein force-pushed the suggest-mode-autosave branch from 9978bd3 to f9d22c7 Compare May 15, 2026 14:27
@adamsilverstein adamsilverstein changed the base branch from add-suggestion-mode to phase-5b-collab-sidebar-actions May 15, 2026 14:27
@adamsilverstein adamsilverstein added [Type] Feature New feature to highlight in changelogs. [Feature] Notes Phase 3 of the Gutenberg roadmap around block commenting labels May 15, 2026
@adamsilverstein adamsilverstein self-assigned this May 15, 2026
adamsilverstein added a commit that referenced this pull request May 18, 2026
Three e2e tests asserted behavior not present on this branch; they were
masked until the JS build break was fixed and the suite could run.

editor-intent-switcher: the intent is session-scoped by design (see
setEditorIntent / editorIntent reducer) - reload returns to Edit. Rewrite
the reload test to assert that reset instead of expecting Suggest to
persist, which the implementation deliberately refuses.

suggestion-mode: 'auto-saves a content edit' and the heading-level
capture test wait for an automatic debounced POST /wp/v2/comments. The
debounced auto-save subsystem is Phase 6 (#78308), not in this stack's
ancestry; here a suggestion is only persisted via the explicit commit-bar
Submit button. Skip both with a tracking reference to #78308.
@adamsilverstein adamsilverstein requested review from Mamaduka and t-hamano and removed request for ajitbohra, fabiankaegy, juanmaguitar and spacedmonkey May 18, 2026 22:13
@adamsilverstein adamsilverstein added Backport from WordPress Core Pull request that needs to be backported to a Gutenberg release from WordPress Core and removed [Package] Editor /packages/editor labels May 18, 2026
@adamsilverstein adamsilverstein added [Type] Enhancement A suggestion for improvement. and removed [Type] Feature New feature to highlight in changelogs. labels May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backport from WordPress Core Pull request that needs to be backported to a Gutenberg release from WordPress Core [Feature] Notes Phase 3 of the Gutenberg roadmap around block commenting [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant